<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>远程控制网络通断-test</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
    <style>
        :root {
            --primary-color: #409EFF;
            --success-color: #67C23A;
            --danger-color: #F56C6C;
            --text-color: #303133;
        }

        body {
            font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
            line-height: 1.6;
            color: var(--text-color);
            margin: 0;
            padding: 20px;
            background: #f5f7fa;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
        }

        h1 {
            color: var(--primary-color);
            text-align: center;
            margin-bottom: 10px;
        }

        h2 {
            font-size: 1.2em;
            color: #606266;
            text-align: center;
            margin-bottom: 30px;
        }

        .input-group {
            margin-bottom: 25px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #DCDFE6;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .button-group {
            display: flex;
            gap: 15px;
            margin-bottom: 25px;
            flex-wrap: wrap;
        }

        button {
            flex: 1;
            padding: 12px 20px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s;
        }

        #connectBtn {
            background-color: var(--success-color);
            color: white;
        }

        #disconnectBtn {
            background-color: var(--danger-color);
            color: white;
        }

        button:hover {
            opacity: 0.9;
            transform: translateY(-1px);
        }

        #statusBox {
            padding: 15px;
            border-radius: 6px;
            text-align: center;
            font-weight: bold;
            transition: all 0.3s;
        }

        .connected {
            background-color: #e1f3d8;
            color: var(--success-color);
        }

        .disconnected {
            background-color: #fde2e2;
            color: var(--danger-color);
        }

        @media (max-width: 480px) {
            .container {
                padding: 20px;
            }
            
            button {
                flex: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>远程网络控制模拟</h1>
        <h2>模拟日志文件修改，触发远程网络管理终端断开互联网</h2>
        <pre><code class="language-bash"># 仅适用于chrome浏览器，启动方式:
chrome.exe --disable-web-security --user-data-dir="C:/ChromeDevSession"</code></pre>
        <div class="input-group">
            <label for="serverId">远程终端IP地址：</label>
            <input type="text" id="serverId" value="192.168.32.232">
        </div>

        <div class="button-group">
            <button id="connectBtn" type="button">模拟触发-接通互联网</button>
            <button id="disconnectBtn" type="button">模拟触发-断开互联网</button>
        </div>

        <div id="statusBox"></div>


    </div>

    <script>
        $(document).ready(function() {
            function sendRequest(status) {
                const serverIp = $('#serverId').val().trim();
                const apiUrl = `http://${serverIp}:9999/manage/control`;
                
                $.ajax({
                    url: apiUrl,
                    type: 'POST',
                    data: { status: status },
                    success: function(response) {
                        if (response.success) {
                            const statusText = status === 1 ? 
                                '互联网已接通' : '互联网已断开';
                            const statusClass = status === 1 ? 
                                'connected' : 'disconnected';
                            
                            $('#statusBox')
                                .text(statusText)
                                .removeClass()
                                .addClass(statusClass);
                        }
                    },
                    error: function(xhr) {
                        $('#statusBox')
                            .text('请求失败，请检查网络连接')
                            .removeClass()
                            .addClass('disconnected');
                    }
                });
            }

            $('#connectBtn').click(() => sendRequest(1));
            $('#disconnectBtn').click(() => sendRequest(0));
        });
        hljs.highlightAll();
    </script>
</body>
</html>
    